
define(['jquery','jquery-cookie','bootstrap','layer','jquery-soChange'],function($){

    window.showMiddleImg = function(){
        $('.small>img').hover(function () {
            this.className = 'hoveredThumb';
            //小图: images\products\product-s3.jpg
            //中图: images/products/product-s3-m.jpg
            var src = this.src.replace(/.png$/, '-m.png');
            $(this).parent().parent().parent().siblings().children(".mediumImg").attr('src', src);

        }, function () {
            this.className = '';
        });
    };

    //全部栏目页飘窗
    $(function(){
        if($(".floating").length > 0){
            $(window).scroll(function(){
                var ling=$(document).scrollTop();
                if(ling>600){
                    $(".floating").slideDown(100);
                }else{
                    $(".floating").slideUp(100);
                }
            })
        }
    });

    //除开首页的左侧全部分类
    $(function(){
        if($("#allshop").length > 0){
            $("#allshop").hover(function () {
                    $("#allshop").children(".allshops").css("display","block");
                },
                function () {
                    $("#allshop").children(".allshops").css("display","none");
                });
        }

    });

    function sleep(numberMillis) {
        var now = new Date();
        var exitTime = now.getTime() + numberMillis;
        while (true) {
            now = new Date();
            if (now.getTime() > exitTime)
                return;
        }
    }

   $(document).ready(function(){
       //点击搜索按钮
       if($("#search_button").length > 0){

           $(".selectbox ol li").click(function (e) {
               e.stopPropagation();
               e.preventDefault();

               var html = $("a",this).html();
               $(".selectbox span.selected").html("搜"+html);
               $(".selectbox ol li").removeClass('current');
               $(this).addClass('current');

           });

           $("#search_button").click(function(e){
               e.stopPropagation();
               e.preventDefault();

               //获取搜索商品还是文章
               var index = $(".selectbox ol li.current").index();
               var keyword = $("#keyword").val();
               if(keyword == ''){
                   if(index == 1){
                       alert('请输入要搜索的关键词');
                   }else{
                       alert('请输入像要找的宝贝');
                   }
                   return false;
               }

               if(index == 1){
                   window.open("/search/news/"+keyword+".html");
               }else{
                   window.open("/search/goods/"+keyword+".html");
               }
           });

           //
           document.onkeydown = function(e){
               var ev = document.all ? window.event : e;
               if(ev.keyCode==13) {
                   $("#search_button").click();
               }
           }
       }
   });



    //搜索公共的
    $(function(){
        $(".selectbox").mouseover(function () {
            $(".selectbox").children("ol").css("display","block");
        });
        $(".selectbox").mouseleave(function () {
            $(".selectbox").children("ol").css("display","none");
        });
    });


    $(function(){
        //当前是IE8
        var browser=navigator.appName;

        var b_version=navigator.appVersion;
        var version=b_version.split(";");
        if(version.length <= 1){
            return ;
        }
        var trim_Version=version[1].replace(/[ ]/g,"");
        if(browser=="Microsoft Internet Explorer" && trim_Version=="MSIE8.0")
        {
            if($(".list .newshop li:nth-child(2n)").length>0){
                $(".list .newshop li:nth-child(2n)").css('margin-left','10px');
            }

            if($('.column .content .frocks li:nth-child(5n)').length>0){
                $('.column .content .frocks li:nth-child(5n)').css('margin-right','0px');
            }
            if( $('.pinkage .clean li:nth-child(4n)').length>0){
                $('.pinkage .clean li:nth-child(4n)').css('margin-right','0px');
            }
            if($('.sale .sales ul li:nth-child(3n)').length>0){
                $('.sale .sales ul li:nth-child(3n)').css('margin-right','0px');
            }
        }
    });


    $(function(){
        if($(".product-img").length > 0){

            $(".product-img").hover(function() { //当鼠标移上去时

                    //它的兄弟图片透明度降到0.7
                    $(this).stop().fadeTo("slow",0.8);
                },
                function() { //当鼠标移出的时候
                    //它的兄弟图片透明度回到1
                    $(this).stop().fadeTo("slow",1);
                });
        }

    });
    $(function(){
        $(document).scroll(function(){
            var  scrollTop =  $(document).scrollTop(),bodyHeight = $(window).height();
            if(scrollTop > bodyHeight){
                $('.go_top').css('display','block');
            }else{
                $('.go_top').css('display','none');
            }
        })

    });


});

